package org.kotboot.enums;

import org.kotboot.kit.K;

/**
 * jisong.sun 2017/9/19 17:20
 */
public enum  PostageModel implements CodeEnum<PostageModel> {
    FREE(1,"包邮")
    ,FARAWAY(2,"偏远不包")
    ,JZH(3,"江浙沪")
    ,CHARGES(4,"不包");

    private int code;

    private String depict;

    PostageModel(int code,String depict){
        this.code = code;
        this.depict = depict;
    }

    public static PostageModel of(String depict){
        if(K.isEmpty(depict)) return null;
        for(PostageModel p:PostageModel.values()){
            if(p.depict.equals(depict)){
                return p;
            }
        }
        return null;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String toString() {
        return depict;
    }
}
